package com.woniuxy.Dynamic.client;

import com.woniuxy.Dynamic.cglib.GongChang;
import com.woniuxy.Dynamic.jdk.GongChang2;
import com.woniuxy.Dynamic.service.ShangPinFuwu;
import com.woniuxy.Dynamic.service.impl.ShangPinFuwuImpl;

public class Test {
    @org.junit.Test
    public void maidongxi(){
        ShangPinFuwuImpl shangpin = new ShangPinFuwuImpl();
        shangpin.maiB();
        GongChang gongChangA = new GongChang();
        ShangPinFuwuImpl shangpinA = (ShangPinFuwuImpl)gongChangA.jiaGong(shangpin);
        shangpinA.maiA();
        GongChang2 gongChangB = new GongChang2();
        ShangPinFuwu shangpinB = (ShangPinFuwu)gongChangB.jiaGong(shangpin);
        shangpinB.maiB();
        System.out.println(shangpin.getClass());
        //工厂A是生成了商品的子类对象
        System.out.println(shangpinA.getClass().getSuperclass());
        //工厂B是生成了Proxy的子类对象，或许可以理解成长得一样用法一样，但是和原本没什么关系了
        System.out.println(shangpinB.getClass().getSuperclass());
        System.out.println(shangpinB.getClass().getSuperclass().getSuperclass());
    }
}
